package com.xjc.market.frame.tag;

import javax.servlet.jsp.tagext.BodyTagSupport;

/**
 * 
 * @author HanqingLiu
 *
 */
public class Mytag4sysconfig extends BodyTagSupport{
	
	private static final long serialVersionUID = 1L;
	
	private String key;
	private String is;
	private String def;
	
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getIs() {
		return is;
	}
	public void setIs(String is) {
		this.is = is;
	}
	public void setDef(String def) {
		this.def = def;
	}
	public String getDef() {
		return def;
	}

	public int doStartTag(){
		/*try {
			Object result = null;
			if(key==null){
			}else if(key.equals("view_count_web")){//customer 记录网站流量次数
				WebApplicationContext context=WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
				CommonService  commonService = (CommonService) context.getBean("CommonService");
				
				//Long count = 10000000000L + commonService.recordView("web", true);
				Long count = commonService.recordView("web", true);
				
				result = count.toString();
				
			}else{
				if(WebStart.sysconfig.containsKey(key)){
					result = WebStart.sysconfig.get(key);
					if(result==null) result = "";
				}
				else{
					result = "";
				}
			}
			if(is==null) {
				JspWriter out= pageContext.getOut();
				if((result==null || result.equals("")) && def!=null) result= def;
				
				out.print(result);
			}
			if(is!=null && result.equals(is)) return EVAL_BODY_INCLUDE;
		} catch (Exception e) {
			e.printStackTrace();
		}
		*/
		return SKIP_BODY;
	}
	
	public static java.lang.String config(java.lang.String keys, java.lang.String def){
		Object result = "";
		/*try {
			if(keys==null){}
			else{
				if(WebStart.sysconfig.containsKey(keys)){
					result = WebStart.sysconfig.get(keys);
					if(result==null) result = "";
				}
				else{
					result = "";
				}
			}
			if((result==null || result.equals("")) && def!=null) result= def;
				
		} catch (Exception e) {
			e.printStackTrace();
		}*/
		return (String)result;
	}
	
	public int doEndTag(){
        return  EVAL_BODY_INCLUDE;
	}
}
